<?php

namespace App\Agent\Controllers;

use App\Http\Controllers\BaseController;
use Dcat\Admin\Form;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Card;

class ConfigController extends BaseController
{
    public function index(Content $content)
    {
        // 标题和内容
        $card = Card::make("配置信息",new \App\Agent\Forms\Config());
        // 设置间距
        $card->padding('0 15px 0 12px');
        if (env('APP_DEBUG')){
            // 设置工具按钮
            $addUrl = "config/create";
            $addClass = "btn btn-sm btn-primary shadow-none create-config";
            $addButton = '<button class="'.$addClass.'"><i class="fa fa-plus"></i>新增配置</button>';
            $card->tool($addButton);
            Form::dialog("新增配置")->click(".create-config")
                ->url($addUrl)->width('1200px')->success('Dcat.reload()');
        }
        // 设置底部内容
        return $content
            ->translation($this->translation())
            ->title($this->title())
            ->description($this->description()['index'] ?? trans('admin.list'))
            ->body($card);
    }
}
